﻿@model KL.Store.Web.Models.ProductEditModel
@using KL.Store.Core;
@using CaptchaMvc.HtmlHelpers;
@{
    Layout = null;
}
<h3>Ürün Bilgileri</h3>
<hr />
@using (Ajax.BeginForm(null, null, null, new AjaxOptions { HttpMethod = "Post", OnBegin = "loadingMsg();" }, new { id = "productedit", name = "productedit", @class = "form-horizontal editform" }))
{
    
    <div class="form-group">
        <label for="Name" class="col-xs-2 control-label first">Ürün Adı <span class="requireStar">*</span> : </label>
        <div class="col-xs-6 first">
            @Html.TextBoxFor(model => model.ProductName, new { @class = "form-control", @placeHolder = "Ürünün adını giriniz" })
            @Html.ValidationMessageFor(model => model.ProductName)
        </div>
        <div class="col-xs-4 first">
            @Html.TextBoxFor(model => model.ProductName2, new { @class = "form-control", @placeHolder = "Ürünün açıklaması giriniz" })
            @Html.ValidationMessageFor(model => model.ProductName2)
        </div>
    </div>
    <div class="form-group">
        <label for="Name" class="col-xs-2 control-label first">Model : </label>
        <div class="col-xs-10 first">
            @Html.TextBoxFor(model => model.Model, new { @class = "form-control", @placeHolder = "Model giriniz" })
            @Html.ValidationMessageFor(model => model.Model)
        </div>
    </div>
    if (ViewBag.Category == 0)
    {
    <div class="form-group">
        <label for="CategoryId" class="col-xs-2 control-label first">Kategori <span class="requireStar">*</span> : </label>
        <div class="col-xs-10 first">
            <select name="CategoryId" class="form-control" style="width: 100%;" id="CategoryId">
                @foreach (var ct in Model.Categories)
                {
                    <option value="@ct.CategoryId">@(ct.CategoryName) (@(ct.CategoryId)) - (Üst Grup: @(ct.ParentCategoryName) - @(ct.ParentCategoryId))</option>
                }
            </select>
        </div>
    </div>
    }
    else
    {
    <input type="hidden" name="CategoryId" value="@ViewBag.Category" />
    }
    <div class="form-group">
        <label for="Name" class="col-xs-2 control-label first">Marka <span class="requireStar">*</span> : </label>
        <div class="col-xs-10 first">
            @Html.DropDownListFor(m => m.SelectedBrand, new SelectList(Model.Brands, "GroupId", "GroupName"), new { @class = "form-control", @style = "width:100%", id = "brandSelect", onchange = "submitBrand();" })
        </div>
    </div>
    <div class="form-group">
        <label for="Description" class="col-xs-2 control-label first">Ürün Detayı: </label>
        <div class="col-xs-10 first">
            @Html.TextAreaFor(model => model.Description, new { @class = "form-control ckeditor", @placeHolder = "Ürünün açıklamasını giriniz" })
            @Html.ValidationMessageFor(model => model.Description)
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-2 first">
            <div class="checkbox">
                <label>
                    @Html.CheckBoxFor(model => model.IsActive)
                    Aktif
                </label>
            </div>
            <div class="checkbox">
                <label>
                    @Html.CheckBoxFor(model => model.CheckStock)
                    Stok Tut
                </label>
            </div>
        </div>
        <div class="col-xs-10 first last">
            <div class="col-xs-2 first">
                <label for="UstUrunId" class="control-label">Üst Ürün ID'si: </label>
                @Html.TextBoxFor(model => model.UstUrunId, new { @class = "form-control", @placeHolder = "Üst Ürün ID'sini giriniz" })
                @Html.ValidationMessageFor(model => model.UstUrunId)
            </div>
            <div class="col-xs-2 first">
                <label for="Price" class="control-label">Fiyatı<span class="requireStar">*</span> : </label>
                @Html.TextBoxFor(model => model.Price, new { @class = "form-control", @placeHolder = "Ürünün fiyatını giriniz" })
                @Html.ValidationMessageFor(model => model.Price)
            </div>
            <div class="col-xs-2 first">
                <label for="TaxRate" class="control-label">KDV Oranı<span class="requireStar">*</span> : </label>
                @Html.TextBoxFor(model => model.TaxRate, new { @class = "form-control", @placeHolder = "KDV oranını giriniz" })
                @Html.ValidationMessageFor(model => model.TaxRate)
            </div>
            @if (Model.IsAllowedBuyPrice)
            {
                <div class="col-xs-2 first right">
                    <label for="DealerSellingPrice" class="control-label">AlışFiyatı : </label>
                    @Html.TextBoxFor(model => model.DealerSellingPrice, new { @class = "form-control", @placeHolder = "Ürünün alış fiyatını giriniz" })
                    @Html.ValidationMessageFor(model => model.DealerSellingPrice)
                </div>
            }
        </div>
    </div>
    <div class="gsp"></div>
    <div class="form-group">
        <div class="col-xs-2 first">
            <div class="checkbox">
                <label>
                    @Html.CheckBoxFor(model => model.FreeCargo)
                    Ücretsiz Kargo
                </label>
            </div>
            <div class="checkbox">
                <label>
                    @Html.CheckBoxFor(model => model.FastCargo)
                    Hızlı Kargo
                </label>
            </div>
        </div>
        <div class="col-xs-10 first">
            <div class="col-xs-2 first">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.NewProduct)
                        Yeni Ürün
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.OpportunityProduct)
                        Fırsat Ürünü
                    </label>
                </div>
            </div>
            <div class="col-xs-2 first">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.CampaignProduct)
                        Kampanyalı Ürün
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.ShowAsCampaignProduct)
                        Kampanyalı Ürün Gösterimi
                    </label>
                </div>
            </div>
            <div class="col-xs-5 first">
                <div class="col-xs-6 first last">
                    <label for="GiftString" class="control-label">Hediye Metni: </label>
                    @Html.TextBoxFor(model => model.GiftString, new { @class = "form-control", @placeHolder = "Hediye metnini giriniz" })
                    @Html.ValidationMessageFor(model => model.GiftString)
                </div>
                <div class="col-xs-6 last">
                    <label for="SpecialText" class="control-label">Özel Metin: </label>
                    @Html.TextBoxFor(model => model.SpecialText, new { @class = "form-control", @placeHolder = "Özel metin giriniz" })
                    @Html.ValidationMessageFor(model => model.SpecialText)
                </div>
            </div>
        </div>
    </div>
    <div class="gsp"></div>
    <div class="form-group">
        <h5>Nakliye, Teslimat ve Garanti</h5>
        <div class="col-md-6 first last">
            <div class="col-xs-3 first">
                <label for="Width" class="control-label">En (cm): </label>
                @Html.TextBoxFor(model => model.Width, new { @class = "form-control", @placeHolder = "En giriniz" })
                @Html.ValidationMessageFor(model => model.Width)
            </div>
            <div class="col-xs-3 first">
                <label for="Length" class="control-label">Boy (cm): </label>
                @Html.TextBoxFor(model => model.Length, new { @class = "form-control", @placeHolder = "Boy giriniz" })
                @Html.ValidationMessageFor(model => model.Length)
            </div>
            <div class="col-xs-3 first">
                <label for="Height" class="control-label">Yükseklik (cm): </label>
                @Html.TextBoxFor(model => model.Height, new { @class = "form-control", @placeHolder = "Yükseklik giriniz" })
                @Html.ValidationMessageFor(model => model.Height)
            </div>
        </div>
        <div class="col-xs-6">
            <div class="col-xs-3 first">
                <label for="DeliveryTime" class="control-label">Teslim Süresi: </label>
                @Html.TextBoxFor(model => model.DeliveryTime, new { @class = "form-control", @placeHolder = "Teslim süresini giriniz" })
                @Html.ValidationMessageFor(model => model.DeliveryTime)
            </div>
            <div class="col-xs-3 first">
                <label for="DeliveryPeriod" class="control-label">Teslim Periyodu: </label>
                @{var Deliveryperiods = new List<SelectListItem> {
                new SelectListItem {Text = "Saat", Value = "Saat"},
                new SelectListItem {Text = "Gün", Value = "Gün"},
                new SelectListItem {Text = "Hafta", Value = "Hafta"},
                new SelectListItem {Text = "Ay", Value = "Ay"}
            };
                }
                @Html.DropDownListFor(model => model.DeliveryPeriod, Deliveryperiods, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.DeliveryPeriod)
            </div>
            <div class="col-xs-3 first">
                <label for="DiscountTotal" class="control-label">İndirim Miktarı: </label>
                @Html.TextBoxFor(model => model.DiscountTotal, new { @class = "form-control", @placeHolder = "İndirim miktarını giriniz" })
                @Html.ValidationMessageFor(model => model.DiscountTotal)
            </div>
            <div class="col-xs-3 first last">
                <label for="DiscountPercent" class="control-label">İndirim Yüzdesi: </label>
                @Html.TextBoxFor(model => model.DiscountPercent, new { @class = "form-control", @placeHolder = "İndirim yüzdesini giriniz" })
                @Html.ValidationMessageFor(model => model.DiscountPercent)
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-6 first last">
            <div class="col-xs-3 first">
                <label for="Desi" class="control-label">Desi: </label>
                @Html.TextBoxFor(model => model.Desi, new { @class = "form-control", @placeHolder = "Desi giriniz" })
                @Html.ValidationMessageFor(model => model.Desi)
            </div>
            <div class="col-xs-3 first">
                <label for="Weight" class="control-label">Ağırlık: </label>
                @Html.TextBoxFor(model => model.Weight, new { @class = "form-control", @placeHolder = "Ağırlık giriniz" })
                @Html.ValidationMessageFor(model => model.Weight)
            </div>
            <div class="col-xs-3 first">
                <label for="CargoPrice" class="control-label">Kargo Ücreti (TL): </label>
                @Html.TextBoxFor(model => model.CargoPrice, new { @class = "form-control", @placeHolder = "Kargo ücretini giriniz" })
                @Html.ValidationMessageFor(model => model.CargoPrice)
            </div>
            <div class="col-xs-3 first last">
                <label for="AddtCargoPrice" class="control-label">Kargo Ek Ücreti (TL): </label>
                @Html.TextBoxFor(model => model.AddtCargoPrice, new { @class = "form-control", @placeHolder = "Ek Kargo ücretini giriniz" })
                @Html.ValidationMessageFor(model => model.AddtCargoPrice)
            </div>
        </div>
        <div class="col-xs-6">
            <div class="col-xs-3 first">
                <label for="VarrantyTime" class="control-label">Garanti Süresi: </label>
                @Html.TextBoxFor(model => model.VarrantyTime, new { @class = "form-control", @placeHolder = "Garanti süresini giriniz" })
                @Html.ValidationMessageFor(model => model.VarrantyTime)
            </div>
            <div class="col-xs-3 first">
                <label for="VarrantyPeriod" class="control-label">Garanti Periyodu: </label>
                @{var VarrantyPeriods = new List<SelectListItem> {
                new SelectListItem {Text = "Ay", Value = "Ay"},
                new SelectListItem {Text = "Yıl", Value = "Yıl"}
            };
                }
                @Html.DropDownListFor(model => model.VarrantyPeriod, VarrantyPeriods, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.VarrantyPeriod)
            </div>
            <div class="col-xs-3 first">
                <label for="DiscountDisplayTotal" class="control-label">İndirim Gösterimi: </label>
                @Html.TextBoxFor(model => model.DiscountDisplayTotal, new { @class = "form-control", @placeHolder = "İndirim gösterimi giriniz" })
                @Html.ValidationMessageFor(model => model.DiscountDisplayTotal)
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-12 col-md-6 first last">
            <div class="col-xs-5 first">
                <label for="InstallmentNeeded" class="control-label-left col-xs-12">Kurulum Gerekli</label>
                <div class="col-xs-1 first last">@Html.CheckBoxFor(model => model.InstallmentNeeded)</div>
                <div class="col-xs-6 first last">@Html.TextBoxFor(model => model.InstallmentPrice, new { @class = "form-control", @placeHolder = "Kurulum ücreti" })
                    @Html.ValidationMessageFor(model => model.InstallmentPrice)
                </div>
                <div class="col-xs-2 first last">
                    <label class="control-label-left">&nbsp;TL</label>
                </div>
            </div>
            <div class="col-xs-4 first">
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.FreeCargoInCity)
                        Ş.içi Ücr. Kargo
                    </label>
                </div>
                <div class="checkbox">
                    <label>
                        @Html.CheckBoxFor(model => model.FreeInstallmentInCity)
                        Ş.içi Ücr. Kurulum
                    </label>
                </div>
            </div>
            <div class=" col-xs-3 first last">
                <label for="Transport" class="control-label">Teslimat: </label>
                <select id="Transport" name="Transport" class="form-control">
                    <option value="Varsayılan">Varsayılan</option>
                    <option value="Tüm Türkiye">Tüm Türkiye</option>
                    <option value="Nakliye">Nakliye</option>
                </select>
            </div>
        </div>
    </div>  
    <hr />
    <div class="form-group">
        <div class="col-xs-12">
            @Html.ValidationSummary(true, "Form gönderilemedi. Lütfen eksik bilgileri kontrol ediniz.")
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-12 first alignright">
            <a class="btn btn-custom1" id="closeForm">Kapat</a>
            <input type="submit" class="btn btn-custom1" value="Kaydet" />
        </div>
    </div>
}
<script>
    function urunEklendi(id)
    {
        $('#processResult').show('fast').html('<div class="bg-info"><p><i class="fa fa-info-circle"></i>&nbsp;Ürün Eklendi.</p></div>');
        if ($.browser.webkit)
        {
            $('body:not(:animated)').animate({ scrollTop: 0 }, 'slow');
        }
        else
        {
            $('html:not(:animated)').animate({ scrollTop: 0 }, 'slow');
        }
        window.location.href = "/ProductManage/Edit/" + id;
    }
</script>
